package com.java.comprehensive.thread.threa_1;

/**
 * @program: comprehensive-service
 *
 * @description:
 *
 * @author: 窦绍飞
 *
 * @create: 2021-12-06 17:50
 **/
public class Thread3 {
	public static void main(String[] args) {
		Object lock = new Object();
		Thread t = new Thread(() -> {
			int num = 1000;
			String s = "";
			for (int i = 0; i < num; i++) {
				s += "Java";
			}
			System.out.println("t Over");
			lock.notify();// 子线程唤醒
		});
		// 计时
		long start = System.currentTimeMillis();
		System.out.println("start = " + start);
		// 启动子线程
		t.start();
		try {
			lock.wait();// 主线程等待
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		long end = System.currentTimeMillis();
		System.out.println("end = " + end);
		System.out.println("end - start = " + (end - start));

	}
}
